  <?php
 /* 
  <url>
		<loc>http://www.123.com.tw/index.php?action=detail&pid=9</loc>
		<data>
			<display>
				<id>9</id><!--團購唯一ID-->
				<website>123團購網</website><!--網站名稱-->
				<siteurl>http://www.123.com.tw/?index.php?aid=7</siteurl><!--網站連接-->
				<city>Taipei</city><!--城市名-->
				<title>123甜點美食可口好吃，尤其是店家自製冰淇淋甜而不膩，帶有濃厚的水果口味，吃入口中散發出清晰的水果清香。</title><!--標題-->
				<image>http://static.123.com.tw/img/team/2011/01/25/12959274341565.jpg</image><!--圖片-->
				<startTime>1297440000</startTime><!--開始時間戳-->
				<endTime>1297699199</endTime><!--結束时间戳-->
				<value>400</value><!--原價-->
				<price>200</price><!--現價-->
				<rebate>5</rebate><!--折扣-->
				<bought>6</bought><!--已購買數量-->
			</display>
		</data>
	</url>
	*/
  $books = array();
  $books [] = array(
  'loc' => 'http://www.123.com.tw/index.php?action=detail&pid=9',
  'id' => '9',
  'website' => "buy917",
  'siteurl' => 'http://www.123.com.tw/?index.php?aid=7',
  'city' => 'taipei',
  'title' => '123甜點美食可口好吃，尤其是店家自製冰淇淋甜而不膩，帶有濃厚的水果口味，吃入口中散發出清晰的水果清香。',
  'image' => 'http://static.123.com.tw/img/team/2011/01/25/12959274341565.jpg',
  'startTime' => '1297440000',
  'endTime' => '1297440000',
  'value' => '400',
  'price' => '200',
  'rebate' => '5',
  'bought' => '6'
  );
  
  $doc = new DOMDocument();
  $doc->formatOutput = true;
  
  $r = $doc->createElement( "urlset" );
  $doc->appendChild( $r );
  
  foreach( $books as $book )
  {
  $b = $doc->createElement( "url" );
  
  $loc = $doc->createElement( "loc" );
  $loc->appendChild($doc->createTextNode($book['loc']));
  $b->appendChild( $loc );


//   $c = $doc->createElement("data");

   
  $title = $doc->createElement( "data" );
  $title->appendChild($doc->createElement("display"));
  $title->appendChild($doc->createElement("title"));
  $title->appendChild(
  $doc->createTextNode( $book['title'] ));
  $b->appendChild( $title );
  
  $publisher = $doc->createElement( "id" );
  $publisher->appendChild(
  $doc->createTextNode( $book['id'] )
    
  );
  $b->appendChild( $publisher );
  
  $r->appendChild( $b );
  
  }
  
  echo $doc->saveXML();
  ?>